//
// Created by 11510 on 2024/6/11.
//
#include <iostream>
using namespace std;

// 复数
class Complex{
private:
    int _real;
    int _image;

public:
    Complex(int real, int image):_real(real), _image(image){}

    void print() const{
        cout << _real << " + " << _image << "i" << endl;
    }

    /**
     * 返回值也可以是void，但是表达式cx1 += cx2没有返回值了
     * @param rhs
     * @return
     */
    Complex& operator+=(const Complex& rhs){
        _real += rhs._real;
        _image += rhs._image;
        return *this;
    }
};



void test0(){
    Complex cx1(1, 2);
    Complex cx2(3, 4);
    cx1 += cx2;
    cx1.print();
}


int main() {
    test0();
    return 0;
}